package dataObject;
import java.util.*;

import dataView.Rank;
public class Brand {
	private String name;
	private ArrayList<Product> productlist;
	
	public Brand(String name){
		this.name = name;
		productlist = new ArrayList<Product>();
	}
	
	public String getName(){
		return name;
	}
	
	public void setUpProduct(String productName,String releaseDate,double size,int price,int batterySize,int cameraPixel,int availableColor)
	{
		Product targetproduct = findProduct(productName);
		if(targetproduct==null)
		{
			Product product = new Product(productName,releaseDate,size,price,batterySize,cameraPixel,availableColor);
			productlist.add(product);
		}
	}
	
	public Product findProduct(String productname)
	{
		for(int i=0;i<productlist.size();i++)
		{
			if(productlist.get(i).getName().equals(productname))
			{
				return productlist.get(i);
			}
		}
		return null;
	}
	
	public void printProductList()
	{
		for(Product p:productlist)
		{
			p.printList();
			
		}
	}
	
	public void genAllProduct(ArrayList<Rank> allProduct)
	{
		for(Product a:productlist)
		{	
			allProduct.add(new Rank(a));
		}
	}
	
	//for testing only
	public ArrayList<Product> getProductList()
	{
		return productlist;
	}
}
